package com.huxiu;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.huxiu.utils.Constants;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengDownloadListener;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UpdateResponse;


public class UpdateActivity extends Activity {
    @ViewInject(R.id.umeng_update_content)
    private TextView umeng_update_content;

    @ViewInject(R.id.layout_exit)
    private RelativeLayout layout_exit;

    @ViewInject(R.id.layout_quilk_update)
    private RelativeLayout layout_quilk_update;

    private UpdateResponse mUpdateResponse;

    private UpdateActivity instance;

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        setContentView(R.layout.app_update_dialog);
        ViewUtils.inject(this);
        instance=this;
        mUpdateResponse= (UpdateResponse) getIntent().getSerializableExtra(Constants.UMENG_UPDATE_INTENT_KEY);
        umeng_update_content.setText(mUpdateResponse.updateLog);
    }

    @OnClick({R.id.layout_exit,R.id.layout_quilk_update})
    public void mOnclick(View v) {
        switch (v.getId()) {
            case R.id.layout_exit:
                this.finish();
                break;
            case R.id.layout_quilk_update:
                UmengUpdateAgent.startDownload(instance, mUpdateResponse);

                this.finish();
                break;
        }
    }


    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("SplashScreen");
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("SplashScreen");
        MobclickAgent.onPause(this);
    }

}
